package com.suneast.suneaststore.ui.fragments;

import android.os.Bundle;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.suneast.suneaststore.R;

import butterknife.ButterKnife;
import butterknife.Unbinder;
import me.yokeyword.fragmentation.SupportFragment;
import me.yokeyword.fragmentation.anim.FragmentAnimator;

public abstract class AbsBaseFragment extends SupportFragment {

    public static final String TAG = "tag";

    private Unbinder mUnBinder = null;

    public abstract @LayoutRes
    int setLayout();

    public abstract void onBindView(@Nullable Bundle savedInstanceState, @NonNull View rootView);

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        super.onCreateView(inflater, container, savedInstanceState);
        final View rootView;
        rootView = inflater.inflate(setLayout(), container, false);
        mUnBinder = ButterKnife.bind(this, rootView);
        onBindView(savedInstanceState, rootView);
        setFragmentAnimator(new FragmentAnimator(R.anim.no_anim, R.anim.no_anim, R.anim.no_anim, R.anim.no_anim));
        return rootView;
    }

    @Override
    public void onDestroyView() {
        if (mUnBinder != null) {
            mUnBinder.unbind();
        }
        super.onDestroyView();
    }

    @Override
    public void post(Runnable runnable) {
    }
}
